import request from '@/utils/request'

// 查询设备列表
export function listDevice(query) {
  return request({
    url: '/pos/device/list',
    method: 'get',
    params: query
  })
}

// 查询设备详细
export function getDevice(deviceId) {
  return request({
    url: '/pos/device/' + deviceId,
    method: 'get'
  })
}

// 新增设备
export function addDevice(data) {
  return request({
    url: '/pos/device',
    method: 'post',
    data: data
  })
}

// 修改设备
export function updateDevice(data) {
  return request({
    url: '/pos/device',
    method: 'put',
    data: data
  })
}

// 删除设备
export function delDevice(deviceId) {
  return request({
    url: '/pos/device/' + deviceId,
    method: 'delete'
  })
}

// 更新设备状态
export function updateDeviceStatus(deviceId, status) {
  return request({
    url: '/pos/device/status/' + deviceId + '/' + status,
    method: 'put'
  })
}

// 获取设备心跳信息（监控用）
export function getDeviceHeartbeat(deviceId) {
  return request({
    url: '/pos/device/heartbeat/' + deviceId,
    method: 'get'
  })
}

// 设备配置更新
export function updateDeviceConfig(deviceId, configData) {
  return request({
    url: '/pos/device/config/' + deviceId,
    method: 'put',
    data: configData
  })
}


// 导出设备列表
export function exportDevice(query) {
  return request({
    url: '/pos/device/export',
    method: 'post',
    data: query
  })
}

// 发送调试指令到设备
export function sendDebugCommand(deviceId, command) {
  return request({
    url: '/pos/device/debug/' + deviceId,
    method: 'post',
    data: { command: command }
  })
}

// 获取设备调试日志
export function getDeviceDebugLogs(deviceId, query) {
  return request({
    url: '/pos/device/debug/logs/' + deviceId,
    method: 'get',
    params: query
  })
}

// 清除设备调试日志
export function clearDeviceDebugLogs(deviceId) {
  return request({
    url: '/pos/device/debug/clear/' + deviceId,
    method: 'post'
  })
}

// 获取设备柜组权限
export function getDeviceGroupPermissions(deviceId) {
  return request({
    url: '/pos/device/permissions/' + deviceId,
    method: 'get'
  })
}

// 设置设备柜组权限
export function setDeviceGroupPermissions(permissionData) {
  return request({
    url: '/pos/device/permissions',
    method: 'post',
    data: permissionData
  })
}

